<template>
  <div>
    <!-- <div>我是home页内容</div> -->
    <!-- <ul>
      <li v-for="item in tabArr" :key="item.title">
        <router-link :to="{name:item.name}" exact>{{item.title}}</router-link>
      </li>
    </ul> -->
    <!-- 这只是包一下告诉缓存否，内部的router-view坑还是执行的 -->
    <!-- <keep-alive :exclude="excludeComponents">
      <router-view v-if="metaId"></router-view>
    </keep-alive>
    <router-view v-if="!metaId" /> -->
    <!-- <router-view /> -->
  </div>
</template>

<script lang="ts">
import Vue from 'vue'
import { RouteMeta } from 'vue-router/types/router'
export default Vue.extend({
  name: 'homePage',
  data () {
    return {
      tabArr: [
        { name: 'tab1', title: '页签1' },
        { name: 'tab2', title: '页签2' },
        { name: 'tab3', title: '页签3' }
      ],
      inputData: [
        { id: 1, name: 'A' },
        { id: 14, name: 'B' },
        { id: 37, name: 'H', parentId: 14 },
        { id: 38, name: 'H', parentId: 37 },
        { id: 39, name: 'H', parentId: 37 }
      ]
    }
  },
  computed: {
    excludeComponents () {
      return this.$store.state.excludeComponents
    },
    metaId () {
      return (this.$route.meta as RouteMeta).keepAlive
    }
  },
  methods: {
    //
    // handleOutPut (arr:Array<any>) {
    //   const res = []
    //   const _data = this.inputData.reduce((total:any, item:any) => {
    //     total[item.id] = item
    //     item.children = []
    //     return total
    //   }, {})
    //   console.log('_data', _data)
    //   for (const item of arr) {
    //     if (!item.parentId) {
    //       res.push(item)
    //       continue
    //     }
    //     if (item.parentId in _data) {
    //       _data[item.parentId].children.push(item)
    //     }
    //   }
    // console.log('res', res)

    // return res
    // }
  }
})
</script>

<style lang="scss" scoped>
// ul{
//   width: 300px;
//   height: 60px;
//   display: flex;
//   justify-content: space-between;
// }
// ul li{
//   list-style: none;
// }

// li a{
//   color:#000;
//   text-decoration: none;
//   font-size: 20px;
// }
// .router-link-active{
//   color:violet;
// }
</style>
